#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	cin>>T;
	while(T--){
		int n,m,l,V;
		cin>>n>>m>>l>>V;
		int d[n],v[n],a[n],dl[n],p[m];
		for(int i=0;i<n;i++){
			cin>>d[i]>>v[i]>>a[i];
			if(a[i]!=0)
				dl[i]=d[i]+(V*V-v[i]*v[i])/(2*a[i]);
		}
		for(int i=0;i<m;i++){
			cin>>p[i];
		}
		int ans1=0;
		for(int i=0;i<n;i++){
			if(v[i]>V)
				ans1++;
		}
		cout<<ans1<<" "<<m-1<<endl;
	}
	return 0;
}
